﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WorldConqueror.Libraries.Maths.Costants;
using WorldConqueror.Libraries.Maths.MathShapes;
using WorldConqueror.Libraries.Maths.ExtensionMethods;

namespace WorldConqueror.Libraries.Maths.Functions.Distance
{
    public interface IDistanceBetweenCoordinates : ITwoParamsFunction<IMathCoordinate, IMathCoordinate, double>
    {
    }

    public abstract class DistanceBetweenCoordinates : IDistanceBetweenCoordinates
    {
        public DistanceBetweenCoordinates(IMathCoordinate parameter1, IMathCoordinate parameter2)
        {
            Parameter1 = parameter1;
            Parameter2 = parameter2;
        }

        public IMathCoordinate Parameter1
        {
            get;
            private set;
        }

        public IMathCoordinate Parameter2
        {
            get;
            private set;
        }

        public double Calculate()
        {
            return CalculateBase(
                Parameter1.Latitude.ToRadians(), Parameter1.Longitude.ToRadians(),
                Parameter2.Latitude.ToRadians(), Parameter2.Longitude.ToRadians());
        }

        public abstract double CalculateBase(
            double radiansLatitude1, double radiansLongitude1,
            double radiansLatitude2, double radiansLongitude2);
    }
}
